package com.jz.netthings.core.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.jz.netthings.core.bean.demo.DemoUser;
import com.jz.netthings.core.dao.mysql.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author yyy
 * @ClassName DemoService
 * @Description TODO
 * @date 2018/7/30 17:12
 */
@Service
public class DemoService {

    @Autowired
    UserMapper userMapper;
//    @Autowired
//    EmpMapper empMapper;

    @Transactional
    public void testInsert(){
        DemoUser user = new DemoUser("谈四个个","甘肃岷县");
        user.setAge("10");
        int result = userMapper.insert(user);
        //插入后会自动回写主键值
        System.out.println("插入成功【"+result+"】条...ID值为："+user.getId());
    }

    public void querAll(){
        System.out.println(userMapper.queryAllDemoUser());
    }


    public void queryAllDemoUser(){

        Page<DemoUser> page = new Page<DemoUser>(3,3);

        List<DemoUser> users = userMapper.selectPage(page,null);

        System.out.println(users);
    }


}
